//
//  WHNTableViewCell.m
//  城市
//
//  Created by dllo on 15/11/5.
//  Copyright © 2015年 Hner. All rights reserved.
//

#import "WHNTableViewCell.h"

@implementation WHNTableViewCell

-(UILabel *)NumberLabel
{
    if (!_NumberLabel) {
        _NumberLabel = [[UILabel alloc]init];
        [_NumberLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_NumberLabel];
    }
    return _NumberLabel;
}
-(UIImageView *)MainImageView
{
    if (!_MainImageView) {
        _MainImageView = [[UIImageView alloc]init];
        [self addSubview:_MainImageView];
    }
    return _MainImageView;
}
-(UILabel *)TitleLabel
{
    if (!_TitleLabel) {
        _TitleLabel = [[UILabel alloc]init];
        [_TitleLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_TitleLabel];
    }
    return _TitleLabel;
}
-(UILabel *)NameLabel
{
    if (!_NameLabel) {
        _NameLabel = [[UILabel alloc]init];
        [_NameLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_NameLabel];
    }
    return _NameLabel;
}
-(UIImageView *)IconImageView
{
    if (!_IconImageView) {
        _IconImageView = [[UIImageView alloc]init];
        [self addSubview:_IconImageView];
    }
    return _IconImageView;
}
-(UILabel *)JiLabel
{
    if (!_JiLabel) {
        _JiLabel = [[UILabel alloc]init];
        [_JiLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_JiLabel];
    }
    return _JiLabel;
}
-(UIImageView *)LeftImageView
{
    if (!_LeftImageView) {
        _LeftImageView = [[UIImageView alloc]init];
        [self addSubview:_LeftImageView];
    }
    return _LeftImageView;
}
-(UIButton *)DownLoadButton
{
    if (!_DownLoadButton) {
        _DownLoadButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self addSubview:_DownLoadButton];
    }
    return _DownLoadButton;
}
-(UILabel *)LineLabel
{
    if (!_LineLabel) {
        _LineLabel = [[UILabel alloc]init];
        [self addSubview:_LineLabel];
    }
    return _LineLabel;
}
-(UIImageView *)iconImageView1
{
    if (!_iconImageView1) {
        _iconImageView1 = [[UIImageView alloc]init];
        [self addSubview:_iconImageView1];
    }
    return _iconImageView1;
}
-(UIImageView *)iconImageView2
{
    if (!_iconImageView2) {
        _iconImageView2 = [[UIImageView alloc]init];
        [self addSubview:_iconImageView2];
    }
    return _iconImageView2;
}
-(UIImageView *)iconImageView3
{
    
    if (!_iconImageView3) {
        _iconImageView3 = [[UIImageView alloc]init];
        [self addSubview:_iconImageView3];
    }
    return _iconImageView3;
}
-(UILabel *)CountLabel
{
    if (!_CountLabel) {
        _CountLabel = [[UILabel alloc]init];
        [_CountLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_CountLabel];
    }
    return _CountLabel;
}
-(UILabel *)TimeLabel
{
    if (!_TimeLabel) {
        _TimeLabel = [[UILabel alloc]init];
        [_TimeLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_TimeLabel];
    }
    return _TimeLabel;
}
-(UILabel *)LikeLabel
{
    if (!_LikeLabel) {
        _LikeLabel = [[UILabel alloc]init];
        [_LikeLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_LikeLabel];
    }
    return _LikeLabel;
}
-(UILabel *)CommentLabel
{
    if (!_CommentLabel) {
        _CommentLabel = [[UILabel alloc]init];
        [_CommentLabel NightWithType:UIViewColorTypeNormal];
        [self addSubview:_CommentLabel];
    }
    return _CommentLabel;
}
-(UISwitch *)swch
{
    if (!_swch) {
        _swch = [[UISwitch alloc]init];
        [self addSubview:_swch];
    }
    return _swch;
}



-(void)setKind:(WHNTableViewCellKind)kind
{
    if (_kind != kind) {
        _kind = kind;
    }
    switch (kind) {
            //左侧一个图, 右侧两个label(有排行label)
        case WHNTableViewCellKindOne:{
            self.NumberLabel.frame = CGRectMake(0, 10 * FitHeight, 40 * FitWidth, 80 * FitHeight);
            _NumberLabel.textAlignment = 1;
            self.MainImageView.frame = CGRectMake(_NumberLabel.frame.origin.x + _NumberLabel.frame.size.width, _NumberLabel.frame.origin.y, 80 * FitHeight, 80 * FitHeight);
            _MainImageView.layer.cornerRadius = _NumberLabel.frame.size.height / 2;
            _MainImageView.layer.masksToBounds = YES;
            self.TitleLabel.frame = CGRectMake(_MainImageView.frame.origin.x + _MainImageView.frame.size.width + 10 * FitWidth, _MainImageView.frame.origin.y, ScreenWidth - _NumberLabel.frame.size.width - _MainImageView.frame.size.width - 50 * FitWidth, 50 * FitHeight);
            _TitleLabel.numberOfLines = 0;
            self.NameLabel.frame = CGRectMake(_TitleLabel.frame.origin.x, _TitleLabel.frame.origin.y + _TitleLabel.frame.size.height, _TitleLabel.frame.size.width, 20 * FitHeight);
            self.LineLabel.frame = CGRectMake(_NameLabel.frame.origin.x, _NameLabel.frame.origin.y + _NameLabel.frame.size.height + 9 * FitHeight, ScreenWidth - _NumberLabel.frame.size.width - _MainImageView.frame.size.width - 10 * FitWidth, 1 * FitHeight);
            _LineLabel.backgroundColor = [UIColor lightGrayColor];
            self.DownLoadButton.frame = CGRectMake(_NameLabel.frame.origin.x + _NameLabel.frame.size.width + 10 * FitWidth, _NameLabel.frame.origin.y, 20 * FitHeight, 20 * FitHeight);
            break;
        }
            //左侧一个图, 右侧三个label,第三行前有小图(有排行label)
        case WHNTableViewCellKindTwo:
            self.NumberLabel.frame = CGRectMake(0, 10 * FitHeight, 40 * FitWidth, 80 * FitHeight);
            _NumberLabel.textAlignment = 1;
            self.MainImageView.frame = CGRectMake(_NumberLabel.frame.origin.x + _NumberLabel.frame.size.width, _NumberLabel.frame.origin.y, 80 * FitHeight, 80 * FitHeight);
            _MainImageView.layer.cornerRadius = 5;
            _MainImageView.layer.masksToBounds = YES;
            self.TitleLabel.frame = CGRectMake(_MainImageView.frame.origin.x + _MainImageView.frame.size.width + 10 * FitWidth, _MainImageView.frame.origin.y, ScreenWidth - _NumberLabel.frame.size.width - _MainImageView.frame.size.width - 50  * FitWidth, 20 * FitHeight);
            self.NameLabel.frame = CGRectMake(_TitleLabel.frame.origin.x, _TitleLabel.frame.origin.y + _TitleLabel.frame.size.height + 5 * FitHeight, _TitleLabel.frame.size.width, 20 * FitHeight);
            self.IconImageView.frame = CGRectMake(_NameLabel.frame.origin.x, _NameLabel.frame.origin.y + _NameLabel.frame.size.height + 5 * FitHeight, 20 * FitHeight, 20 * FitHeight);
            self.JiLabel.frame = CGRectMake(_IconImageView.frame.origin.x + _IconImageView.frame.size.width, _IconImageView.frame.origin.y, _NameLabel.frame.size.width - _IconImageView.frame.size.width, _IconImageView.frame.size.height);
            self.LineLabel.frame = CGRectMake(_IconImageView.frame.origin.x, _IconImageView.frame.origin.y + _IconImageView.frame.size.height + 9 * FitHeight, ScreenWidth - _NumberLabel.frame.size.width - _MainImageView.frame.size.width - 10 * FitWidth, 1 * FitHeight);
            _LineLabel.backgroundColor = [UIColor lightGrayColor];
            self.LeftImageView.frame = CGRectMake(_NameLabel.frame.origin.x + _NameLabel.frame.size.width + 10 * FitWidth, _NameLabel.frame.origin.y, 20 * FitHeight, 20 * FitHeight);
            
            break;
            //左侧一个图, 右侧三个label,第三行前有小图
        case WHNTableViewCellKindThree:
            self.MainImageView.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, 80 * FitHeight, 80 * FitHeight);
            _MainImageView.layer.cornerRadius = 5;
            _MainImageView.layer.masksToBounds = YES;
            self.TitleLabel.frame = CGRectMake(_MainImageView.frame.origin.x + _MainImageView.frame.size.width + 10 * FitWidth, _MainImageView.frame.origin.y, ScreenWidth - _MainImageView.frame.size.width - 30  * FitWidth, 20 * FitHeight);
            self.NameLabel.frame = CGRectMake(_TitleLabel.frame.origin.x, _TitleLabel.frame.origin.y + _TitleLabel.frame.size.height + 5 * FitHeight, _TitleLabel.frame.size.width, 20 * FitHeight);
            self.IconImageView.frame = CGRectMake(_NameLabel.frame.origin.x, _NameLabel.frame.origin.y + _NameLabel.frame.size.height + 5 * FitHeight, 20 * FitHeight, 20 * FitHeight);
            self.CountLabel.frame = CGRectMake(_IconImageView.frame.origin.x + _IconImageView.frame.size.width, _IconImageView.frame.origin.y, _NameLabel.frame.size.width - _IconImageView.frame.size.width, _IconImageView.frame.size.height);
            self.LineLabel.frame = CGRectMake(_IconImageView.frame.origin.x, _IconImageView.frame.origin.y + _IconImageView.frame.size.height + 9 * FitHeight, ScreenWidth - _MainImageView.frame.size.width - 20 * FitWidth, 1 * FitHeight);
            _LineLabel.backgroundColor = [UIColor lightGrayColor];
            self.LeftImageView.frame = CGRectMake(_NameLabel.frame.origin.x + _NameLabel.frame.size.width + 10 * FitWidth, _NameLabel.frame.origin.y, 20 * FitHeight, 20 * FitHeight);
            
            break;
            
        case WHNTableViewCellKindFour://女神榜声音
            self.MainImageView.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, 60 * FitHeight, 60 * FitHeight);
            _MainImageView.layer.cornerRadius = 60 * FitHeight / 2;
            _MainImageView.layer.masksToBounds = YES;
            self.TitleLabel.frame = CGRectMake(_MainImageView.frame.origin.x + _MainImageView.frame.size.width + 10 * FitWidth, _MainImageView.frame.origin.y, ScreenWidth - _MainImageView.frame.size.width - 50 * FitWidth, 20 * FitHeight);
            _TitleLabel.numberOfLines = 0;
            self.NameLabel.frame = CGRectMake(_TitleLabel.frame.origin.x, _TitleLabel.frame.origin.y + _TitleLabel.frame.size.height, _TitleLabel.frame.size.width, 20 * FitHeight);
            self.IconImageView.frame = CGRectMake(_NameLabel.frame.origin.x, _NameLabel.frame.origin.y + _NameLabel.frame.size.height, 20 * FitHeight, 20 * FitHeight);
            _IconImageView.image = [UIImage imageNamed:@"sanjiao1"];
            self.CountLabel.frame = CGRectMake(_IconImageView.frame.origin.x + _IconImageView.frame.size.width, _IconImageView.frame.origin.y, 50 * FitWidth, _IconImageView.frame.size.height);
            
            self.iconImageView1.frame = CGRectMake(_CountLabel.frame.origin.x + _CountLabel.frame.size.width, _CountLabel.frame.origin.y, _IconImageView.frame.size.width, _IconImageView.frame.size.height);
            _iconImageView1.image = [UIImage imageNamed:@"xin"];
            self.LikeLabel.frame = CGRectMake(_iconImageView1.frame.origin.x + _iconImageView1.frame.size.width, _iconImageView1.frame.origin.y, _CountLabel.frame.size.width, _CountLabel.frame.size.height);
            self.iconImageView2.frame = CGRectMake(_LikeLabel.frame.origin.x + _LikeLabel.frame.size.width, _LikeLabel.frame.origin.y, _IconImageView.frame.size.width, _IconImageView.frame.size.height);
            _iconImageView2.image = [UIImage imageNamed:@"pinglun"];
            self.CommentLabel.frame = CGRectMake(_iconImageView2.frame.origin.x + _iconImageView2.frame.size.width, _iconImageView2.frame.origin.y, _LikeLabel.frame.size.width, _LikeLabel.frame.size.height);
            self.iconImageView3.frame = CGRectMake(_CommentLabel.frame.origin.x + _CommentLabel.frame.size.width, _CommentLabel.frame.origin.y, _iconImageView2.frame.size.width, _iconImageView2.frame.size.height);
            _iconImageView3.image = [UIImage imageNamed:@"f-shijian"];
            self.TimeLabel.frame = CGRectMake(_iconImageView3.frame.origin.x + _iconImageView3.frame.size.width, _iconImageView3.frame.origin.y, _CommentLabel.frame.size.width, _CommentLabel.frame.size.height);

            self.LineLabel.frame = CGRectMake(0, _IconImageView.frame.origin.y + _IconImageView.frame.size.height + 10 * FitHeight, ScreenWidth, 5 * FitHeight);
            _LineLabel.backgroundColor = [UIColor lightGrayColor];
            self.DownLoadButton.frame = CGRectMake(325 * FitWidth, _NameLabel.frame.origin.y, 40 * FitHeight, 40 * FitHeight);
            break;
        case WHNTableViewCellKindFive://夜间模式cell
            self.TitleLabel.frame = CGRectMake(15 * FitWidth, 15 * FitHeight, ScreenWidth - 100 * FitHeight, self.frame.size.height - 20 * FitHeight);
            self.swch.frame = CGRectMake(300 * FitWidth, 15 * FitHeight, 70 * FitWidth, _TitleLabel.frame.size.height - 20 * FitHeight);
            break;
        case WHNTableViewCellKindSix://收藏cell
            self.MainImageView.frame = CGRectMake(10 * FitWidth, 10 * FitHeight, 40 * FitHeight, 40 * FitHeight);
            self.TitleLabel.frame = CGRectMake(_MainImageView.frame.origin.x + _MainImageView.frame.size.width + 10 * FitWidth, _MainImageView.frame.origin.y + 10 * FitHeight, ScreenWidth - _MainImageView.frame.size.width - 40 * FitWidth, 20 * FitHeight);
            
            break;
        default:
            break;
    }
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self NightWithType:UIViewColorTypeNormal];
    }
    return self;
}

















- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
